#include "errorLog.h"

ErrorLog* ErrorLog::instance = NULL;

/*
    Is singleton
    Gives a possibility to log any errors while server is running
*/
ErrorLog::ErrorLog() {
    // private constructor
}

void ErrorLog::init(QString fileName) {
    if (instance == NULL) {
        instance = new ErrorLog();
        instance->fileName = fileName;
    }
    // @todo open file as "a+"
}

void ErrorLog::append(QString message) {
    if (instance->fileName == NULL) {
        EventsManager::show(message);
    } else {
        // @todo write to file
    }
}

void ErrorLog::append(QString message, bool exitApplication) {
    ErrorLog::append(message);
    if (exitApplication) {
        exit(0);
    }
}
